#include <limits.h>  // INT_MIN,INT_MAX
#include <math.h>    // abs,pow

#include <algorithm>      // sort
#include <iostream>       // cout,cin
#include <string>         // string
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <vector>         // vector

using namespace std;

// 如果x是2的幂则返回True，否则返回False
bool IsPowerOf2(int x) { return (x & (x - 1)) == 0; }

class Solution {
   public:
    vector<int> twoSum(vector<int>& numbers, int target) {
        int i1 = 0, i2 = numbers.size() - 1;
        while (i1 < i2) {
            int now = numbers[i1] + numbers[i2];
            if (now > target) {
                i2--;
            } else if (now < target) {
                i1++;
            } else {
                return {i1, i2};
            }
        }
        return {0, 0};
    }
};